# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=libetonyek
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.1.12
pkgrel=2
pkgdesc="Library for import of Apple Keynote presentations. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://wiki.documentfoundation.org/DLP/Libraries/libetonyek'
msys2_references=(
  'archlinux: libetonyek'
)
license=('spdx:MPL-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-liblangtag"
         "${MINGW_PACKAGE_PREFIX}-librevenge"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-gperf"
             "${MINGW_PACKAGE_PREFIX}-glm"
             "${MINGW_PACKAGE_PREFIX}-mdds"
             "${MINGW_PACKAGE_PREFIX}-cppunit")
source=("https://dev-www.libreoffice.org/src/${_realname}/${_realname}-${pkgver}.tar.xz"
        "001-fix-build-with-mdds-3.0.patch")
sha256sums=('b9fa82fbeb8cb7a701101060e4f3e1e4ef7c38f574b2859d3ecbe43604c21f83'
            '1fe7eb1ad697fd74e13fa665b865acbd4e82b8325f990362182d1ae317693743')

prepare() {
  cd "${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}"/001-fix-build-with-mdds-3.0.patch

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --with-mdds=3.0

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"

  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
